package com.hyq.hm.hyperlandmark.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.hyq.hm.hyperlandmark.R;

public class SampleAdapter extends BaseAdapter {

    private Context context;
    public SampleAdapter(Context context) {
        super();
        this.context = context;
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_sample, parent, false);
        }

        ImageView iv = convertView.findViewById(R.id.iv);
        int resid = context.getResources().getIdentifier("pic" + position % 10, "drawable",
                parent.getContext().getPackageName());
        iv.setImageResource(resid);
        return convertView;
    }
}
